home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
parapass.zip
/
PARAPASS.8
< prev
next >
Wrap
Text File
|
1988-05-31
|
18KB
|
387 lines
; PROGRAM : parapass
;
; VERSION : 0.0 (BETA TEST) 10/20/87
;
; INVOCATION : parapass <program name> </q>
; the /q option is quiet option, it won't prompt for
; parameters but will wait to read them
;
; AUTHOR : Rusty Baldwin
; 4783 W. 133rd St. #12
; Hawthorne, CA 90250
;
; LANGUAGE : This program was developed with the A86 assembly language
; if you want to assemble using MASM your on your own.
; To assemble using A86 type : A86 PARAPASS.ASM
;
; A86 can be obtained from: Eric Isaacson
; 416 E. University
; Bloomington, IN 47401
; (812)339-1811
;
;
; DESCRIPTION : This program allows the interactive specification of
; command line parameters. Microsoft EDLIN editor for
; instance requires that the file to be edited be specified
; on the command line (example: edlin myfile.doc). In a
; operating environment such as DESQview this may not be
; convenient however since parameters which are passed in
; environments such as DESQview are static (i.e. you must
; be content to edit myfile.doc constantly). This program
; was developed to get around that problem. When you run
; this program it will prompt you for the file to execute
; (which must have a fully qualified path name) and the
; parameters to pass to that program. It then runs the
; program and 'fools' the program into thinking the para-
; meters were passed on the command line.
;
;
; Miscellaneous Equates
;
space equ 20h ; space
cr equ 0dh ; carriage return
main: call init ; get switches etc. on command line
test b[status],80h ; is quiet bit set?
jnz >l1 ; yes
mov dx,begin_msg ; no, output program header
mov ah,9h
int 21h
l1: mov bx,[2ch] ; specify environment block address
mov [par_blk],bx ; pass the environment we got.
mov [p1],ds ; THIS IS KLUDGEY SO I WANT TO
mov [p2],ds ; DO THIS BETTER LATER
mov [p3],ds
again: mov ch,0 ; clear ch
mov cl,[80h] ; get length of command tail
mov al,[prg_add] ; see if we have a program name
cmp al,0
jne >l1 ; yes we do
getname: mov dx,name_msg ; nope, get program name
mov ah,9h ; this will send prompt even
int 21h ; if quiet bit is set.
mov b[80h],7fh ; allow 128 bytes length
mov dx,80h ; get program name
mov ah,0ah
int 21h
mov ah,[81h] ; get length of read
inc ah ; increase it by one
mov [80h],ah ; with this section we are
mov b[81h],space ; simulating, getting the program
; name on the command line
call init ; call init again
jmp again ; try it again
l1: call valid ; check validity of filename
cmp al,0eh ; invalid name? (0eh invalid
jne >l2 ; file name error code)
jmp alt ; yes, display error message
; use alternate entry point
l2: mov si,[prg_add] ; source pointer to name of program to run
and si,0ffh ; make sure msb is zero
mov di,prg_nam ; destination pointer
l3: mov al,[si] ; get a byte
mov [di],al ; put it in destination
inc si ; take care of pointers and such
inc di
loop l3 ; go get some more
mov b[si],' ' ; put ' : $' at end of command tail for later use
inc si ; so we can output to user
mov b[si],':'
inc si
mov b[si],'$'
test b[status],80h ; is quiet bit set?
jnz >l1 ; yes
mov dx,crlf ; output crlf
mov ah,9h
int 21h
mov dx,prompt ; prompt for parameters
mov ah,9h ; output it
int 21h
mov dl,[prg_add] ; output program name
mov dh,0
int 21h
mov dx,crlf ; output crlf
mov ah,9h
int 21h
l1: mov dx,cmd_line-1 ; get cmd_line
mov ah,0ah
int 21h
mov dx,crlf ; output crlf
mov ah,9h
int 21h
mov ah,29h ; put cmd_line in FCB #1
mov al,01 ; in case program looks there
mov si,offset cmd_line+1
mov di,ds
mov es,di
mov di,offset fcb1
int 21h
mov [stk_seg],ss ; save stack
mov [stk_off],sp
mov ah,25h ; intercept any <CNTRL> C
mov al,23h ; so we can ingore it
mov dx,int_ret
int 21h ; ds should already be correct
mov ah,4ah ; release memory for EXEC'd program
mov bx,eop-main ; eop-main = program length in bytes
shr bx,4 ; divide bx by 16 for paragraph length
add bx,11h ; add enough to take care of PSP
int 21h ; release memory
mov dx,prg_nam ; set up to EXEC program
mov bx,par_blk
mov al,0
mov ah,4bh
int 21h ; EXEC program
mov ss,[stk_seg] ; restore stack
mov sp,[stk_off]
jc alt ; if error print message
jmp good_exit ; if no error were done
int_ret: iret ; dummy interrupt handler
alt: mov bl,al ; convert error number to ASCII
cmp bl,0ah
jg >l1
add bl,30h ; convert to ASCII 1-9
mov [error],bl
jmp >l2
l1: add bl,37h ; convert to ASCII A-Z
mov [error],bl ; put error number in head_msg
l2: mov dx,head_msg ; output header
push ax ; save ax
mov ah,9h
int 21h
pop ax ; restore it
cmp al,1h ; oh no an error,find out which one
je err1 ; err1=function invalid
cmp al,2h
je err2 ; err2=file not found,path invalid
cmp al,5h
je err5 ; err5=access denied
cmp al,8h
je err